//1:输出空心矩形，矩形的高和宽用户输入， 必须都大于等于3，否则要求重新输入；
public class Task1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        for (; ; ) {
            System.out.println("input height");
            int i, h = in.nextInt();
            System.out.println("input width");
            int w = in.nextInt();
            if (w >= 3 && h >= 3) {
                for (i = 1; i <= h; i++) {
                    for (int k = 1; k <= w; k++) {
                        if (i == 1 || i == h) System.out.print("* ");
                        else if (k == 1 || k == w) System.out.print("* ");
                        else System.out.print("  ");
                    }
                    System.out.println("");
                }
                break;
            } else System.out.println("Error！Input again ！");
        }
    }
}